Retrieving Part Info http://www.macromedia.com/devnet/mx/flash/articles/ria_databases04.html

#include "NetServices.as


myConnection_conn=NetServices.createGatewayConnection(URL);


http://127.0.0.1:8500/flashservices/gateway


myService=myConnection_conn.getService(serviceName,
   defaultResponder);


myService.methodName(responderObject);


responderObject.onResult=function(results){
   ActionScript statements
   }


<cfquery name="qPartInfo" datasource="bikeparts">
  SELECT	Parts.partID, Parts.name, Parts.description,
  Parts.price, PartType.partType
  FROM	Parts, PartType
  WHERE	Parts.partTypeID=PartType.partTypeID
  ORDER BY Parts.name
</cfquery>


#include "NetServices.as" 


var net_conn = NetServices.createGatewayConnection("http://127.0.0.1:8500/flashservices/gateway");


var partService = net_conn.getService("devnet.bikeparts")


var partResponder=new Object();


partService.getPartInfo(partResponder);


partResponder.onResult=function(parts_rs){
}


trace("in the method");


------------------------------------------------------

Populating the ListBox http://www.macromedia.com/devnet/mx/flash/articles/ria_databases05.html

parts_lb.getSelectedItem().data.description


DataGlue.bindFormatFunction(dataConsumer,RecordSet,
   formatFunction );


this.binder=function(record){
  var dataObj=new Object();
  dataObj.label=record.name;
  dataObj.data=record;
  return dataObj;
  }


parameters for the bindFormatFunction()
    * dataConsumer: parts_lb
    * dataProvider: parts_rs
    * formatFunction: binder


partResponder.onResult=function(parts_rs){
    DataGlue.bindFormatFunction(parts_lb,parts_rs,binder);
}


this.binder=function(record){
}



this.binder=function(record){
    var dataObj=new Object();
    dataObj.label=record.name;
    dataObj.data=record;
    return dataObj;
    }


------------------------------------------------------

Implementing Data Drill-Down http://www.macromedia.com/devnet/mx/flash/articles/ria_databases06.html

my_pb.setClickHandler(functionName, [location])



parts_lb.fillTextBoxes=function(){
}



Inside the method, fill the following TextBoxes with the corresponding values from the data portion of the selected item:

    * name_txt.text: parts_lb.getSelectedItem().data.name
    * type_txt.text: parts_lb.getSelectedItem().data.partType
    * price_txt.text: parts_lb.getSelectedItem().data.price
    * desc_txt.text: parts_lb.getSelectedItem().data.description



parts_lb.fillTextBoxes=function(){
  name_txt.text=parts_lb.getSelectedItem().data.name;
  type_txt.text=parts_lb.getSelectedItem().data.partType;
  price_txt.text=parts_lb.getSelectedItem().data.price;
  desc_txt.text=parts_lb.getSelectedItem().data.description;
}


parts_lb.setChangeHandler("fillTextBoxes",parts_lb);


types_cb._visible=false;
addPart_pb._visible=false;


partResponder.onResult=function(parts_rs){
	DataGlue.bindFormatFunction(parts_lb,parts_rs,binder);
	parts_lb.setSelectedIndex(0);
}


----------------------------------------------------------

Transitioning from a Display to an Input Form
http://www.macromedia.com/devnet/mx/flash/articles/ria_databases07.html

parts_lb.addItemAt(0,"Add New Part",null);


DataGlue.bindFormatStrings(dataConsumer,
   RecordSet,
   "#labelColumnName#",
   "#dataColumnName#");


partResponder.onResult=function(parts_rs){
    var tempObj=new Object;
    tempObj.name="Add New Part";
    parts_rs.addItemAt(0,tempObj);
    DataGlue.bindFormatFunction(parts_lb,parts_rs,binder);
    parts_lb.setSelectedIndex(1);
}


<cfquery name="qGetTypes" datasource="bikeparts">
    SELECT	partTypeID, partType
    FROM	PartType 
    ORDER BY partType ASC
</cfquery>



var typeResponder=new Object();


partService.getPartTypes(typeResponder);


typeResponder.onResult=function(types_rs){
    partTypes_rs=types_rs;
}


parts_lb.addPart=function(){
}



In the method, clear any data in the following TextBoxes by setting the text property equal to the empty string:

    * name_txt
    * type_txt
    * price_txt
    * desc_txt



In the method, use the bindFormatStrings() method to populate the ComboBox types_cb. Users should be able to see the partType and assign the partTypeID to the data. Use the following values:

    * dataConsumer: types_cb
    * dataProvider: partTypes_rs
    * labelString: "#partType#"
    * dataString: "#partTypeID#"


parts_lb.addPart=function(){
    type_txt._visible=false;
    types_cb._visible=true;
    addPart_pb._visible=true;
    name_txt.text="";
    type_txt.text="";
    price_txt.text="";
    desc_txt.text="";
    DataGlue.bindFormatStrings(types_cb,partTypes_rs, "#partType#","#partTypeID#");
}




At the top of the method, set the _visible property of the following objects to the value shown:

    * type_txt: true
    * types_cb: false
    * addParts_pb: false



parts_lb.fillTextBoxes=function(){
    type_txt._visible=true;
    types_cb._visible=false;
    addPart_pb._visible=false;
    name_txt.text=parts_lb.getSelectedItem().data.name;
    type_txt.text=parts_lb.getSelectedItem().data.partType;
    price_txt.text=parts_lb.getSelectedItem().data.price;
    desc_txt.text=parts_lb.getSelectedItem().data.description;
}


parts_lb.displayOrAdd=function(){
}


parts_lb.displayOrAdd=function(){
    if (parts_lb.getSelectedIndex() == 0){
    parts_lb.addPart();
    }else{
    parts_lb.fillTextBoxes();
    }
}


parts_lb.setChangeHandler("displayOrAdd",parts_lb);


-------------------------------------------------------------

Writing to the Database
http://www.macromedia.com/devnet/mx/flash/articles/ria_databases08.html

<cffunction name="insertPart" access="remote" returntype="numeric">
<cfargument name="name" required="true" type="string">
<cfargument name="description" required="true" type="string">
<cfargument name="price" required="true" type="numeric">
<cfargument name="partTypeID" required="true" type="numeric">


<cfquery datasource="bikeparts">
  INSERT INTO Parts (name,description,price,partTypeID)
  VALUES ('#name#','#description#',#price#,#partTypeID#)
< /cfquery>


<cfquery name="qPartID" datasource="bikeparts">
  SELECT max(partID) AS partNumber
  FROM Parts
< /cfquery>


<  /cftransaction>
<cfreturn qPartID.partNumber>
</cffunction>


var insertResponder=new Object();


addPart_pb.insertData=function(){
}


In the insertData method, call the partService.insertPart() method. Pass the following arguments, in the order shown:

    * insertResponder
    * name_txt.text
    * desc_txt.text
    * Number(price_txt.text)
    * Number(types_cb.getSelectedItem().data)



addPart_pb.insertData=function(){
    partService.insertPart(insertResponder,
    name_txt.text,
    desc_txt.text,
    Number(price_txt.text),
    Number(types_cb.getSelectedItem().data));
}


addPart_pb.setClickHandler("insertData",addPart_pb);


insertResponder.onResult=function(itemNumber){
}


insertResponder.onResult=function(itemNumber){
    newItem_txt._visible=true;
    newItem_txt.text="The ID for your new product
    is "+itemNumber;
}


newItem_txt._visible=false;


insertResponder.onResult=function(itemNumber){
    partService.getPartInfo(partResponder);
}


------------------------------------------------------------

End of file.